package cn.heckman.springbatch.batchTaskCommon;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.atomic.AtomicLong;

@Configuration
public class SpringBatchCommonConfig {

    //号码总数量计数
    public static AtomicLong totalNum = new AtomicLong();
    public static AtomicLong whiteNum = new AtomicLong();
    public static AtomicLong blackNum = new AtomicLong();
    public static AtomicLong otherNum = new AtomicLong();


    /**
     * 定义线程池
     *
     * @return
     */
    @Bean
    public TaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setMaxPoolSize(50);
        taskExecutor.setCorePoolSize(10);
        taskExecutor.setQueueCapacity(20);
        return taskExecutor;
    }

}
